package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.api.admin.AdchannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController  implements AdchannelControllerApi {
    @Autowired
    private AdChannelService channelService;

    @PostMapping("/list")
    @Override
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto) {
        return channelService.findByNameAndPage(dto);
    }

    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdChannel adChannel) {
        return channelService.save(adChannel);
    }

    @Override
    @GetMapping("/{id}")
    public ResponseResult findById(@PathVariable("id") Integer id) {
        return channelService.findById(id);
    }

    @Override
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return channelService.update(adChannel);
    }

    @Override
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        return channelService.delete(id);
    }

    @Override
    @DeleteMapping("/deletes")
    public ResponseResult deletes(@RequestBody Integer[] ids) {
        return channelService.deletes(ids);
    }

    @Override
    @GetMapping("/channels")
    public ResponseResult findAll() {
        return channelService.findAll();
    }
}
